﻿using Interview.Model;
using System.Diagnostics;
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
using Interview.Model.Enum;
using Interview.Service;
using Interview.Model.ExaminationQuestions2;

// 试题1
MilkTeaShop shop = new MilkTeaShop();

// 问题1：中杯高奶低糖多珍珠
MilkTea milkTea1 = shop.CreateMilkTea(CupgradeEnum.Medium);
Console.WriteLine(milkTea1.cupgrade);

milkTea1.AddIngredient(new Milk(IngredientgradeEnum.More));
milkTea1.AddIngredient(new Sugar(IngredientgradeEnum.Less));
milkTea1.AddIngredient(new Pearl(IngredientgradeEnum.More));

Console.WriteLine("问题1结果：");
Console.WriteLine(milkTea1);

// 问题2：大杯高茶中糖多芒果少布丁
MilkTea milkTea2 = shop.CreateMilkTea(CupgradeEnum.Big);
milkTea2.AddIngredient(new Tea(IngredientgradeEnum.More));
milkTea2.AddIngredient(new Sugar(IngredientgradeEnum.Medium));
milkTea2.AddIngredient(new Mango(IngredientgradeEnum.More));
milkTea2.AddIngredient(new Pudding(IngredientgradeEnum.Less));

Console.WriteLine("问题2结果：");
Console.WriteLine(milkTea2);

// 问题3：实现排队功能
Console.WriteLine("问题3结果：");

shop.PlaceOrder(milkTea1);
shop.PlaceOrder(milkTea2);

//大杯高奶少茶多糖多珍珠
MilkTea milkTea3 = shop.CreateMilkTea(CupgradeEnum.Big);
milkTea3.AddIngredient(new Milk(IngredientgradeEnum.More));
milkTea3.AddIngredient(new Tea(IngredientgradeEnum.Less));
milkTea3.AddIngredient(new Sugar(IngredientgradeEnum.More));
milkTea3.AddIngredient(new Pearl(IngredientgradeEnum.More));
shop.PlaceOrder(milkTea3);
//小杯少奶高茶低糖
MilkTea milkTea4 = shop.CreateMilkTea(CupgradeEnum.Small);
milkTea4.AddIngredient(new Milk(IngredientgradeEnum.Less));
milkTea4.AddIngredient(new Tea(IngredientgradeEnum.More));
milkTea4.AddIngredient(new Sugar(IngredientgradeEnum.Less));

shop.PlaceOrder(milkTea4);

// 显示队列长度
Console.WriteLine($"排队订单数: {shop.GetQueueLengthNum()}");

// 处理订单
while (shop.GetQueueLengthNum() > 0)
{
    shop.ProcessOrder();
}

Console.WriteLine("所有订单 done!");


// 试题2
MeSwitch smartSwitch = new MeSwitch();
var riceCooker = new RiceCooker();
var roboticvacuumCleaner = new RoboticvacuumCleaner();
var oven = new Oven();
var electricLight = new ElectricLight();
smartSwitch.AddAppliance(riceCooker);
smartSwitch.AddAppliance(roboticvacuumCleaner);


Console.WriteLine("问题1结果：");
smartSwitch.TurnOn();
smartSwitch.TurnOff();


Console.WriteLine("问题2结果：");
smartSwitch.AddAppliance(oven);
smartSwitch.AddAppliance(electricLight);
smartSwitch.TurnOn();
smartSwitch.TurnOff();




// 模拟开关操作
Console.WriteLine("问题4演示：");
smartSwitch.TurnOn();

// 模拟检查电器状态
Console.WriteLine("运行...");
for (int i = 0; i < 5; i++)
{
    Console.WriteLine($"\n第 {i + 1} 次检查:");

    // 模拟 电灯突然error
    if (i == 2) electricLight.Status = ElectricalStatusEnum.Err;

    if (i == 3) electricLight.Status = ElectricalStatusEnum.Working;

    smartSwitch.CheckAllElectrical();
    System.Threading.Thread.Sleep(500);
}

smartSwitch.TurnOff();

Console.WriteLine("\n按任意键退出...");
Console.ReadKey();






